package StudyCode.summary.zipfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadStringFromStream {
	public static String readStringFromStream(InputStream inputStream) {
		String text;
		InputStreamReader reader = new InputStreamReader(inputStream);
		try {
			text = getString(reader);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		return text;
	}

	private static String getString(Reader reader) throws IOException {
		String text = "";
		BufferedReader bufferedReader = new BufferedReader(reader);
		String line;
		while ((line = bufferedReader.readLine()) != null) {
			text += line + "\n";
		}
		return text;
	}
}
